package java8;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class HashMapTest2 {
    public static void main(String[] args) {
        Stream<String> stream = Stream.of("a", "b", "c", "b", "b", "a");
        Object obj = stream.collect(Collectors.groupingBy(o -> o, Collectors.counting()));
        System.out.println(obj); // {a=2, b=3, c=1}


        System.out.println(Stream.of("a", "b", "c", "b", "b", "a").collect(Collectors.groupingBy(Function.identity(), Collectors.counting())));
    }
}
